﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DCTAccess.Business.Search;
using DCTAccess.Business.Property;
using Utils.DCSControl;
using DCTLib.Common;

public partial class TimKiem_ket_qua_tim_kiem : System.Web.UI.Page
{
    private string strKeyword = string.Empty;
    private string strServices = string.Empty;
    private string strFromPrice = string.Empty;
    private string strToPrice = string.Empty;
    private string strLocation = string.Empty;
    private string strNeed = string.Empty;
    private DataTable dataTable;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            LoadingData();
        }
        catch (System.Exception ex)
        {
        	
        }      
    }

    protected void LoadingData()
    {
        //strKeyword = Request.QueryString["Keyword"];
        //strServices = Request.QueryString["Services"];
        //strFromPrice = Request.QueryString["FromPrice"];
        //strToPrice = Request.QueryString["ToPrice"];
        //strLocation = Request.QueryString["Location"];
        //strNeed = Request.QueryString["rNeed"];         

        try
        {
            //SearchFilter filter = GetSearchDetail();
            //DataTable dataTable = filter.GetSearchResult();
            dataTable = (DataTable)Session["SearchAvance"];
            if (!ValidationHelper.HasRow(dataTable))
            {
                lblResult.Text = "Tìm thấy " + dataTable.Rows.Count + " kết quả phù hợp";
                DatatableHelper.HasNoRow(dataTable, "ProductName", gvSearch);
            }
            else
            {
                lblResult.Text = "Tìm thấy "+ dataTable.Rows.Count + " kết quả phù hợp";
                ControlLoader.BindDatagrid(gvSearch, dataTable, 0);
                
            }
        }
        catch (System.Exception ex)
        {
            //Message = "error";
        }
    }

    public string FormatPrice(object num)
    {
        if (num.ToString() == "-1")
            return "Thỏa thuận";
        return String.Format("{0:#,##}", num);
    }

    public string ReturnImage(object images)
    {
        if (images.Equals(null) || images.Equals(""))
            return "../images/No_Images.gif";
        return images.ToString();
    }

    protected void gvSearch_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        ControlLoader.BindDatagrid(gvSearch, dataTable, e.NewPageIndex);
    }
    protected void btnSearch_Click(object sender, ImageClickEventArgs e)
    {
        //Response.Redirect("/tim-kiem-co-ban.aspx?key=" + Utils.Format.ConvertToNoSign(txtKeyword.Text.Trim()));
    }
    protected void btnAdvanceSearch_Click(object sender, ImageClickEventArgs e)
    {
        //Response.Redirect("/TimKiem/tim-kiem-nang-cao.aspx");
    }
}
